mini.parse();
var grid=mini.get("grid1");
var boxpo=mini.get("boxpo");
var form2=new mini.Form("form2");
//渲染日历
$(document).ready(function(){

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    if($('.calendar').length > 0){
        $('.calendar').fullCalendar({
            buttonText: {
                today: '跳转到今天',
                month: '月视图',
                week: '周视图',
                day: '日视图'
            },

            timeFormat: {
                '': 'H:mm{-H:mm}'
            },
            weekMode: "variable",
            columnFormat: {
                month: 'dddd',
                week: 'dddd M-d',
                day: 'dddd M-d'
            },
            titleFormat: {
                month: 'yyyy年 MMMM月',
                week: "[yyyy年] MMMM月d日 { '&#8212;' [yyyy年] MMMM月d日}",
                day: 'yyyy年 MMMM月d日 dddd'
            },
            monthNames: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
            dayNames: ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
            allDayText: "全天",
            header: {
                left: 'prev,next,today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay',

            },

            editable: true,

            events: [
                {
                    title: '全天事项',
                    start: new Date(y, m, 1),
                    backgroundColor:"red",
                    textColor:"black"

                },
                {
                    title: '长距离项目',
                    start: new Date(y, m, d-5),
                    end: new Date(y, m, d-2)
                },
                {
                    id: 999,
                    title: '重复项目',
                    start: new Date(y, m, d-3, 16, 0),
                    allDay: false
                },
                {
                    id: 999,
                    title: '重复项目',
                    start: new Date(y, m, d+4, 16, 0),
                    allDay: false
                },
                {
                    title: '会议',
                    start: new Date(y, m, d, 10, 30),
                    end:new Date(y, m, d, 11),
                    allDay: true
                },
                {
                    title: '会议2',
                    start: new Date(y, m, d, 10, 30),
                    end:new Date(y, m, d, 11),
                    allDay: false
                },
                {
                    title: '会议3',
                    start: new Date(y, m, d, 10, 35),
                    end:new Date(y, m, d, 10, 55),
                    backgroundColor:"red",
                    allDay: false
                },
                {
                    title: '午餐',
                    start: new Date(y, m, d, 12, 0),
                    end: new Date(y, m, d, 14, 0),
                    allDay: false
                },
                {
                    title: '生日聚会',
                    start: new Date(y, m, d+1, 19, 0),
                    end: new Date(y, m, d+1, 22, 30),
                    allDay: false
                },
                {
                    title: '点击跳转谷歌',
                    start: new Date(y, m, 28),
                    end: new Date(y, m, 29),
                    url: 'http://www.google.com/'
                }
            ]

        });

    }

});

var treep=[
    {id: "base", text: "个人日历"},
    {id: "ajax", text: "生活日历", pid: "base"},
    {id: "json", text: "自建日历", pid: "base"},
    {id: "date", text: "自建日历", pid: "base", checked: true},
    {id: "lists", text: "工作日历"},
    {id: "layouts", text: "我创建的"},
    {id: "navigations", text: "我管理的"},
    {id: "other", text: "Other", isLeaf: false, asyncLoad: false}
]
var griddata=[
    {"dept_id":"rs","id":"1","name":"王多多","Genders":1,"age":28,"Country":"usa"},
    {"dept_id":"cw","id":"2","name":"王健林","Genders":1,"age":19,"Country":"cn"},
    {"dept_id":"cw","id":"3","name":"王思聪","Genders":1,"age":21,"Country":"jp"},
    {"dept_id":"rs","id":"4","name":"胡歌","Genders":1,"age":21,"Country":"en"},
    {"dept_id":"rs","id":"5","name":"张卫健","Genders":2,"age":21,"Country":"de"},
    {"dept_id":"rs","id":"6","name":"血杀保健","Genders":1,"age":21,"Country":"fr"}
];
var griddata2=[
    {"dept_id":"rs","id":"1","name":"王多多","Genders":1,"age":28,"Country":"usa"},
    {"dept_id":"cw","id":"2","name":"王健林","Genders":1,"age":19,"Country":"cn"},

]
grid.setData(griddata);
var tree=mini.get("tree1");
console.log(tree);
tree.loadData (treep);
//画grid里的操作删除按钮
grid.on("drawcell", function (e) {
    var record = e.record,
        column = e.column,
        field = e.field,
        value = e.value;
    if(column.name=="action"){
        e.cellStyle = "text-align:center";
        e.cellHtml = '<a href="javascript:edit(\'' + record.id + '\')">操作</a>&nbsp; '
            + '<a href="javascript:del(\'' + record.id + '\')">删除</a>'
    }
});
function edit() {
    alert("1")
}
//新建日程按钮
function addd() {
    mini.open({

        targetWindow: window,
        url:"newschedule.html",
        title:"新建日程",
        height:"60%",
        width:"50%",
        showMaxButton: true,
        showModal:Boolean,
        allowResize:Boolean,
        setReadOnly:false,
        onload: function () {
            // var iframe = this.getIFrameEl();//备份这个跨子页面窗口
            // var data = {  action: "new"};//父传值给子页面
            // iframe.contentWindow.SetData(data);//跨字串后页面渲染data

        },
        ondestroy: function (action) {
            // if(action=="ok"){
            //     // request('0',pager.getPageSize());
            //     grid.reload();    //页面重新加载
            //
            // }
        }
    })
}
//切换按钮，右面页面以日历的形式展开或者以列表的形式展开
function cutover() {
    var DCE=document.getElementById("DCE");   //获取导出Excel的id
    var DCX=document.getElementById("DCX");   //获取导出Xml的id
    var RCSX=document.getElementById("RCSX"); //获取日程筛选的id
    var SSK=document.getElementById("SSK");    //获取搜索的id
    var CX=document.getElementById("CX");       //获取查询的id

    //当导出Excel的style.display为none隐藏时
    if(DCE.style.display=="none"){
        DCE.style.display="block";    //Excel的style.display为block显示
        DCX.style.display="block";     //导出Xml的style.display为block显示
        RCSX.style.display="block";     //日程筛选的style.display为block显示
        SSK.style.display="block";       //获取搜索的style.display为block显示
        CX.style.display="none";           //查询的style.display为none隐藏
    }else{
        DCE.style.display="none";           //Excel的style.display为none隐藏
        DCX.style.display="none";           //导出Xml的style.display为none隐藏
        RCSX.style.display="none";          //日程筛选的style.display为none隐藏
        SSK.style.display="none";           //获取搜索的style.display为none隐藏
        CX.style.display="block";        //查询的style.display为block显示

    }
   var boxpo= document.getElementById("boxpo");   //获取日历的id
   if(boxpo.style.display!="none"){                         //当日历的disp不等于none时，下一次点击让它none隐藏
       boxpo.style.display="none"
   }else{
       boxpo.style.display="block"
   }


}
//查询切换按钮
function chaxun() {

   var chaxun=  document.getElementById("chaxun");  //获取查询页面的ID
    if(chaxun.style.display=="none"){             //当查询页面上的display为none隐藏时，下次点击为切换block显示
        chaxun.style.display="block"
    }else{
        chaxun.style.display="none"
    }
}
//查询按钮的搜索按键
function finds() {
    var chaxun=  document.getElementById("chaxun");  //获取查询页面的ID
    if(chaxun.style.display=="none"){             //当查询页面上的display为none隐藏时，下次点击为切换block显示
        // chaxun.style.display="block"
    }else{
        chaxun.style.display="none"
    }
    var DCE=document.getElementById("DCE");
    var DCX=document.getElementById("DCX");
    var RCSX=document.getElementById("RCSX");
    var SSK=document.getElementById("SSK");
    var CX=document.getElementById("CX");

    if(DCE.style.display=="none"){
        DCE.style.display="block";              //Excel的style.display为block显示
        DCX.style.display="block";          //导出Xml的style.display为block显示
        RCSX.style.display="block";      //日程筛选的style.display为block显示
        SSK.style.display="block";     //获取搜索的style.display为block显示
        CX.style.display="none";     //查询的style.display为none隐藏
    }else{
        // DCE.style.display="none";
        // DCX.style.display="none";
        // RCSX.style.display="none";
        // SSK.style.display="none";
        // CX.style.display="block";

    }
    var boxpo= document.getElementById("boxpo");   //获取日历的id
    if(boxpo.style.display!="none"){                         //当日历的disp不等于none时，下一次点击让它none隐藏
        boxpo.style.display="none"
    }else{
        // boxpo.style.display="block"
    }

    var data=form2.getData();   //获取form2上的值
    console.log(data);
    data=JSON.stringify(data);  //转化成字符串
    // $.ajax({
    //     url:"",
    //     data:data,
    //     success:function (data) {
    //         grid.setData("");
    //         grid.setData(data);
    //     },
    //     error:function () {
    //
    //     }
    // })

}
function closeWindow(action) {
    if (window.CloseOwnerWindow)
        return window.CloseOwnerWindow(action);
    else
        window.close();
}

function onOk() {
    onSave();
    closeWindow("ok");
}

function onCancel() {
    closeWindow("cancel");
}
function RCSX() {
    alert("日程筛选")
}
function DCE() {
    alert("Excel")
}
function DCX() {
    alert("XML")
}

function fuzzyquery() {

    var chaxun=  document.getElementById("chaxun");  //获取查询页面的ID
    if(chaxun.style.display=="none"){             //当查询页面上的display为none隐藏时，下次点击为切换block显示
        chaxun.style.display="block"
    }else{
        chaxun.style.display="none"
    }
}